package com.itheima.day14.day14work6;

import java.util.Random;
import java.util.TreeMap;
import java.util.concurrent.Callable;
import java.util.concurrent.atomic.AtomicInteger;

public class Door implements Callable<Integer> {
    private final Object obj=new Object();
    volatile int num=0;//统计员工从某门进入的次数
    Random random=new Random();//产生双色球
    volatile static int count=0;
    @Override
    public Integer call() throws Exception {
        TreeMap<Integer,String> tm=new TreeMap<Integer, String>();

        while (true){
          count++;
           // System.out.println(count);
            synchronized (obj){
                StringBuilder sb=new StringBuilder();
                num++;
                sb.append("[");
                for (int i = 0; i < 6; i++) {
                    int ssq = random.nextInt(33) + 1;
                    sb.append(ssq).append(",");
                }
                int i = random.nextInt(16) + 1;
                sb.append(i).append("]");
               // tm.put(count,"sb"); //员工和相应的彩票添加到map集合
                System.out.println(count+"的员工 从"+Thread.currentThread().getName()+" 入场! 拿到的双色球彩票号码是:"+sb);

                if (count==100)
                    break;
            }

        }
        return num;
    }
}
